*************************************************************************************
*																					*
*					ANALYSES APPENDIX	MISSING VALUES								*
*																					*
*************************************************************************************


use "dataset appendix MV jungherr et al RIPE.dta", clear
set scheme plotplainblind

//////////////////////////////
*Table
*Analysis Missing Values
*Distribution Missing Values
*Table S2-1
//////////////////////////////

mdesc freetrade att_ttip_1 ttip_sign_1 ttip_adv_1 ttip_stop_r_1 $specvalues  $isco $inc $utility $values  $elitecues  $controls  $employees ttip_imp_pers_1 ttip_imp_pol_1


*Problematic Variables: Income and Competition
gen inc_miss = F21_1 == 99
gen competition_miss = missing(competition)
gen export_miss = missing(export)

tab2 att_ttip_1_tri inc_miss		   	if !missing(att_ttip_1) & !missing(freetrade), V gamma exp 
tab2 freetrade_tri inc_miss			   	if !missing(att_ttip_1) & !missing(freetrade), V gamma   exp

tab2 att_ttip_1_tri competition_miss	if !missing(att_ttip_1) & !missing(freetrade), V gamma exp 
tab2 freetrade_tri competition_miss		if !missing(att_ttip_1) & !missing(freetrade), V gamma   exp

tab2 att_ttip_1_tri export_miss			if !missing(att_ttip_1) & !missing(freetrade), V gamma exp 
tab2 freetrade_tri export_miss			if !missing(att_ttip_1) & !missing(freetrade), V gamma   exp



	

//////////////////////////////
*Table
*MLogit with MV-Category
//////////////////////////////	
*Figure S9-1	
fre att_ttip_1_tri	freetrade_tri
recode att_ttip_1_tri 	(.=3), gen(att_ttip_1_tri_mv)
recode freetrade_tri 	(.=3), gen(freetrade_tri_mv)		

mlogit att_ttip_1_tri		$specvalues  	$isco 					$values 	$elitecues, baseoutcome(1)
estimates store reg_att_ttip_1_tri
margins, dydx(*)
ereturn list
estimates store att_ttip_1_tri

		 
mlogit att_ttip_1_tri_mv		$specvalues  	$isco 					$values 	$elitecues, baseoutcome(1)
estimates store reg_att_ttip_1_tri_mv
margins, dydx(*)
ereturn list
estimates store att_ttip_1_tri_mv

coefplot 		(att_ttip_1_tri, keep(Oppose:)) 		(att_ttip_1_tri_mv, keep(0:)) , bylabel(Oppose) ///
         || 	(att_ttip_1_tri, keep(Support:))	(att_ttip_1_tri_mv, keep(2:)) , bylabel(Support) ///
         || 	(att_ttip_1_tri_mv, keep(3:)) , bylabel(DKNO)||, ///
		 drop(_cons) xline(0) eform xtitle("") byopts(compact cols(3)) ///
		 xsize(6) legend(label(4 "DKNO dropped") label(2 "DKNO modelled"))
		 


*Figure S9-2
mlogit freetrade_tri		$specvalues  	$isco 					$values 	$elitecues, baseoutcome(1)
estimates store reg_freetrade_tri
margins, dydx(*)
ereturn list
estimates store freetrade_tri

		 
mlogit freetrade_tri_mv		$specvalues  	$isco 					$values 	$elitecues, baseoutcome(1)
estimates store reg_freetrade_tri_mv
margins, dydx(*)
ereturn list
estimates store freetrade_tri_mv

coefplot 		(freetrade_tri, keep(Oppose:)) 		(reg_freetrade_tri_mv, keep(0:)) , bylabel(Oppose) ///
         || 	(freetrade_tri, keep(Support:))	(reg_freetrade_tri_mv, keep(2:)) , bylabel(Support) ///
         || 	(freetrade_tri_mv, keep(3:)) , bylabel(DKNO) 	||, ///
		 drop(_cons) xline(0) eform xtitle("") byopts(compact cols(3)) ///
		 xsize(6) legend(label(4 "DKNO dropped") label(2 "DKNO modelled")) ///
		  transform(* = min(max(@,0),10)) 
		 

*Table S9-1
esttab reg_att_ttip_1_tri	reg_att_ttip_1_tri_mv	reg_freetrade_tri	freetrade_tri_mv using "mlogit_dkno.rtf", replace ///
		title("Regression models of TTIP and Free trade Attitudes, With and Without ‘Don’t Know’ as Explicit Category") ///
		mtitles("TTIP DKNO dropped" "TTIP DKNO dropped"  "Free trade  DKNO dropped" "Free trade DKNO modelled") ///
		nonum nogaps obslast par label ///
		b(2) se(2) ar2(3) nonotes align(l) ///
		addnotes("Notes: Reported are regression coefficients with standard errors in parentheses from a multinomial logistic regression; Base outcome: Party agree / party disagree;*: p<0,05, **: p<0,01, ***: p<0,001.") /// 
		varwidth(30) modelwidth(3)
		 